/* styles.css */
body {
  margin: 0;
  font-family: 'Segoe UI', sans-serif;
  background: #1e1e1e;
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  overflow: hidden;
}

.app-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.camera-preview {
  width: 100%;
  height: 100%;
  position: relative;
}

#camera-feed {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#overlay-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 15px;
  background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.7) 50%, rgba(0,0,0,0) 100%);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 10px;
  z-index: 1000;
}

/* 左侧控制区 */
.left-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 30%;
}

/* 右侧控制区 */
.right-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 30%;
}

/* 中央控制区 */
.center-controls {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 0;
  z-index: 1001;
}

/* 通用按钮样式 */
.control-btn {
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  color: rgba(255, 255, 255, 0.9);
  padding: 6px 10px;
  font-size: 12px;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
  z-index: 10;
  white-space: nowrap;
}

.control-btn:hover {
  background: rgba(0, 0, 0, 0.7);
  border-color: rgba(255, 255, 255, 0.4);
}

.control-btn.active {
  background: rgba(0, 0, 0, 0.8);
  border-color: rgba(255, 255, 255, 0.5);
}

/* 拍摄按钮 */
.capture-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  position: relative;
  z-index: 1002;
}

.capture-button {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  border: 4px solid rgba(255, 255, 255, 0.9);
  padding: 0;
  position: relative;
  transition: all 0.3s ease;
  z-index: 10;
  margin: 0 auto;
}

.capture-button:hover {
  transform: scale(1.05);
  background: rgba(255, 255, 255, 0.4);
}

.capture-button.recording {
  background: rgba(255, 0, 0, 0.6);
  border-color: rgba(255, 0, 0, 0.9);
}

.capture-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.photo-icon {
  width: 32px;
  height: 32px;
  background: white;
  border-radius: 50%;
}

.video-icon {
  width: 24px;
  height: 24px;
  border: 3px solid white;
  border-radius: 50%;
  display: none;
}

.recording-indicator {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 16px;
  height: 16px;
  background: #ff0000;
  border-radius: 50%;
  display: none;
  animation: blink 1s infinite;
}

@keyframes blink {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

.capture-mode-select {
  display: flex;
  gap: 5px;
  background: rgba(0, 0, 0, 0.7);
  padding: 4px;
  border-radius: 20px;
  backdrop-filter: blur(5px);
  z-index: 10;
}

.mode-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.9);
  padding: 4px 8px;
  border-radius: 16px;
  font-size: 12px;
  transition: all 0.3s ease;
}

.mode-btn.active {
  background: rgba(255, 255, 255, 0.9);
  color: black;
}

/* 滑块样式 */
.slider-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  background: rgba(0, 0, 0, 0.5);
  padding: 10px;
  border-radius: 12px;
  backdrop-filter: blur(5px);
  margin-bottom: 15px;
  position: relative;
  z-index: 1002;
}

.slider-container input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  outline: none;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
}

.slider-container input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
}

.slider-container input[type="range"]::-ms-thumb {
  width: 16px;
  height: 16px;
  background: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
}

/* 文本控制面板 */
.text-panel {
  position: absolute;
  top: auto;
  bottom: max(80px, env(safe-area-inset-bottom));
  right: 20px;
  max-height: 40vh;
  min-height: 200px;
  overflow-y: auto;
  z-index: 800;
  background: rgba(255, 255, 255, 0.95);
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.font-size-controls {
  display: flex;
  justify-content: space-between;
  margin-bottom: 15px;
  gap: 10px;
}

.font-size-btn {
  flex: 1;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  min-height: 44px;
}

.font-size-btn:hover {
  background: #f5f5f5;
}

.font-size-icon {
  font-size: 18px;
  font-weight: bold;
  color: #333;
}

.font-size-symbol {
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 12px;
  color: #666;
}

.text-scroll-controls {
  margin-bottom: 15px;
}

.scroll-speed-label {
  font-size: 14px;
  color: #666;
  margin-bottom: 8px;
}

.styled-select {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
  cursor: pointer;
  font-size: 14px;
  color: #333;
}

.custom-scroll-controls {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.custom-scroll-controls input {
  width: 80px;
  padding: 6px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.duration-unit {
  font-size: 14px;
  color: #666;
}

.text-control-buttons {
  display: flex;
  gap: 8px;
}
.control-btn {
  cursor: pointer;
}

.text-control-buttons .control-btn {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 4px;
  background: #4CAF50;
  color: white;
  cursor: pointer;
  transition: background 0.2s ease;
  min-height: 44px;
}

.text-control-buttons .control-btn:hover {
  background: #45a049;
}

#reset-text-position {
  background: #f44336;
}

#reset-text-position:hover {
  background: #da190b;
}

/* 下拉选择框样式 */
.control-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 20px;
  color: white;
  padding: 8px 16px;
  font-size: 14px;
  outline: none;
  backdrop-filter: blur(10px);
}

/* 文本输入弹窗 */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: rgba(0, 0, 0, 0.9);
  padding: 15px;
  border-radius: 12px;
  width: 90%;
  max-height: 80vh;
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
}

#text-input {
  width: 100%;
  height: 150px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: white;
  padding: 12px;
  font-size: 16px;
  resize: none;
  margin-bottom: 15px;
  box-sizing: border-box;
}

#text-input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.4);
}

.modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-buttons .control-btn {
  min-width: 80px;
}

/* 文本覆盖层 */
#text-overlay {
  position: absolute;
  max-height: 70vh;
  overflow: hidden;
  width: 80%;
  max-width: 500px;
  background: transparent;
  /* overflow: scroll; */
  border-radius: 12px;
  color: white;
  font-size: 18px;
  line-height: 1.6;
  z-index: 1000;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.text-content {
  padding: 40px 20px;
  height: 100%;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

/* Custom scrollbar styles */
.text-content::-webkit-scrollbar {
  width: 6px;
}

.text-content::-webkit-scrollbar-track {
  background: transparent;
}

.text-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

/* Control buttons with semi-transparent background */
.play-pause-btn, .close-btn {
  background: rgba(0, 0, 0, 0.5) !important;
  backdrop-filter: blur(5px);
}

.play-pause-btn:hover, .close-btn:hover {
  background: rgba(0, 0, 0, 0.7) !important;
}

.text-position-controls,
.text-size-controls {
  display: flex;
  gap: 5px;
  align-items: center;
}

.text-controls input[type="number"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 5px;
  color: red;
  padding: 5px;
  font-size: 14px;
}

.text-controls input[type="number"]:focus {
  background: rgba(255, 255, 255, 0.2);
  outline: none;
}

.text-controls,.text-controls-show {
  display: flex;
  gap: 10px;
  align-items: center;
  background: rgba(0, 0, 0, 0.7);
  padding: 10px 20px;
  border-radius: 25px;
  backdrop-filter: blur(10px);
}

.text-controls-show {
  display: none;
  color: white;
  justify-content: center;
}

.filter-controls {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.filter-options,
.optimization-options {
  position: absolute;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  padding: 15px;
  border-radius: 12px;
  z-index: 100;
  min-width: 200px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.filter-options {
  left: 0;
  bottom: 100%;
  margin-bottom: 10px;
}

.optimization-options {
  left: 100%;
  top: 0;
  margin-left: 10px;
}

.close-btn {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background-color 0.3s ease;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.filter-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(80px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.filter-btn {
  padding: 8px 15px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 15px;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
}

.filter-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
}

.filter-btn.active {
  background: #007bff;
  border-color: #007bff;
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 10px;
}

.slider-group label {
  color: white;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 14px;
}

.slider-group input[type="range"] {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  outline: none;
}

.slider-group input[type="range"]::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
}

.slider-group input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
}

.slider-group input[type="range"]::-ms-thumb {
  width: 16px;
  height: 16px;
  background: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
}

/* 移除数字输入框的上下箭头 */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  margin: 0;
}

input[type="number"]::-moz-number-spin-box {
  -moz-appearance: none;
  appearance: none;
}

/* 倒计时显示 */
.countdown-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  justify-content: center;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.3);
  z-index: 1000;
  pointer-events: none;
}

.countdown-overlay.active {
  display: flex;
}

.countdown-number {
  font-size: 120px;
  font-weight: bold;
  color: white;
  text-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
  animation: countdownPulse 1s infinite;
}

@keyframes countdownPulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}

/* 延时拍摄按钮 */
.delay-btn {
  position: absolute;
  top: 15px;
  left: 15px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.9);
  color: white;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 100;
  padding: 0;
  overflow: hidden;
}

.delay-btn:hover {
  background: rgba(0, 0, 0, 0.7);
  transform: scale(1.05);
}

.delay-icon,
.delay-number1,
.delay-number2 {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: all 0.3s ease;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  color: white;
}

.delay-number1,.delay-number2 {
  font-size: 24px;
  font-weight: bold;
}

/* 默认显示延时图标 */
.delay-btn .delay-icon {
  opacity: 1;
}

/* 3秒延时状态 */
.delay-btn.delay-3 .delay-icon {
  opacity: 0;
}

.delay-btn.delay-3 .delay-number1 {
  opacity: 1;
  color: white;
  font-weight: bold;
}

/* 6秒延时状态 */
.delay-btn.delay-6 .delay-icon {
  opacity: 0;
}

.delay-btn.delay-6 .delay-number2 {
  opacity: 1;
  color: white;
  font-weight: bold;
}

.media-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  background: rgba(0, 0, 0, 0.7);
  padding: 10px 20px;
  border-radius: 25px;
  backdrop-filter: blur(10px);
}

.speed-controls {
  margin-left: 10px;
  display: flex;
  align-items: center;
}

.speed-controls .control-select {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 20px;
  color: white;
  padding: 8px 16px;
  font-size: 14px;
  outline: none;
  backdrop-filter: blur(10px);
}

.font-size-input {
  width: 50px;
  height: 30px;
  text-align: center;
  margin: 0 5px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
  color: rgba(255, 100, 0, 1);
}

.font-size-input:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

#hide-text-controls {
  margin-left: 10px;
  background-color: rgba(0, 0, 0, 0.5);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s ease;
}

#hide-text-controls:hover {
  background-color: rgba(0, 0, 0, 0.7);
  border-color: rgba(255, 255, 255, 0.5);
}

.reference-controls {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  padding: 8px;
  border-radius: 8px;
  z-index: 900;
  width: 90%;
  max-width: 400px;
  backdrop-filter: blur(5px);
}

.controls-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

#play-pause-btn {
  min-width: 32px;
  width: 32px;
  height: 32px;
  padding: 0;
}

#speed {
  min-width: 50px;
  width: 50px;
  padding: 4px;
  font-size: 12px;
}

.progress-container {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-bar {
  flex: 1;
  min-width: 50px;
}

.time-display {
  min-width: 65px;
  font-size: 11px;
}

/* Media queries for different screen sizes */
@media (max-width: 480px) {
  .controls {
    padding: 10px;
  }

  .capture-button {
    width: 50px;
    height: 50px;
  }

  .control-btn {
    padding: 4px 8px;
    font-size: 11px;
  }

  .reference-controls {
    padding: 6px;
  }

  #play-pause-btn {
    width: 28px;
    height: 28px;
  }

  #speed {
    width: 45px;
  }

  .time-display {
    font-size: 10px;
    min-width: 55px;
  }
}

/* Touch-friendly adjustments */
@media (hover: none) {
  .control-btn,
  .capture-button,
  #play-pause-btn,
  .mode-btn {
    min-height: 44px; /* Minimum touch target size */
  }

  .progress-bar::-webkit-slider-thumb {
    width: 20px;
    height: 20px;
  }

  .progress-bar::-moz-range-thumb {
    width: 20px;
    height: 20px;
  }
}

/* Prevent text selection on controls */
.controls, .reference-controls {
  user-select: none;
  -webkit-user-select: none;
}

/* Safe area insets for modern mobile devices */
@supports (padding: max(0px)) {
  .controls {
    padding-bottom: max(15px, env(safe-area-inset-bottom));
    padding-left: max(15px, env(safe-area-inset-left));
    padding-right: max(15px, env(safe-area-inset-right));
  }
}